Remove draw_insertion_cursor in label and entry
authorPaolo Borelli <pborelli@gnome.org>
Sat, 26 Nov 2011 22:11:08 +0000 (23:11 +0100)
committerPaolo Borelli <pborelli@gnome.org>
Thu, 1 Dec 2011 00:22:38 +0000 (01:22 +0100)
Remove the the draw_insertion_cursor wrapper which just converts from
GtkTextDir to PangoDirection

https://bugzilla.gnome.org/show_bug.cgi?id=640317

gtk/gtkentry.c
gtk/gtklabel.c

index 989b24aff3d56760cc80a1be56c235b20dd5ef9a..c0d8fb2deec5fd2c68074cb5f3776d64e3c567aa 100644 (file)
@@ -5841,27 +5841,6 @@ gtk_entry_draw_text (GtkEntry *entry,
   cairo_restore (cr);
 }
 
-static void
-draw_insertion_cursor (GtkEntry      *entry,
-                       cairo_t       *cr,
-                      GdkRectangle  *cursor_location,
-                      gboolean       is_primary,
-                      PangoDirection direction,
-                      gboolean       draw_arrow)
-{
-  GtkWidget *widget = GTK_WIDGET (entry);
-  GtkTextDirection text_dir;
-
-  if (direction == PANGO_DIRECTION_LTR)
-    text_dir = GTK_TEXT_DIR_LTR;
-  else
-    text_dir = GTK_TEXT_DIR_RTL;
-
-  gtk_draw_insertion_cursor (widget, cr,
-                            cursor_location,
-                            is_primary, text_dir, draw_arrow);
-}
-
 static void
 gtk_entry_draw_cursor (GtkEntry  *entry,
                        cairo_t   *cr,
@@ -5869,7 +5848,7 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
 {
   GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
-  GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
+  GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
   PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
   GdkRectangle cursor_location;
   gboolean split_cursor;
@@ -5901,8 +5880,7 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
   if (!block)
     {
       gint strong_x, weak_x;
-      PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
-      PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
+      GtkTextDirection dir1, dir2;
       gint x1 = 0;
       gint x2 = 0;
 
@@ -5912,15 +5890,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
                     "gtk-split-cursor", &split_cursor,
                     NULL);
 
-      dir1 = priv->resolved_dir;
-  
+      dir1 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+      dir2 = GTK_TEXT_DIR_NONE;
+
       if (split_cursor)
         {
           x1 = strong_x;
 
           if (weak_x != strong_x)
             {
-              dir2 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+              dir2 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
               x2 = weak_x;
             }
         }
@@ -5937,16 +5916,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       cursor_location.width = 0;
       cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
 
-      draw_insertion_cursor (entry, cr,
-                             &cursor_location, TRUE, dir1,
-                             dir2 != PANGO_DIRECTION_NEUTRAL);
-  
-      if (dir2 != PANGO_DIRECTION_NEUTRAL)
+      gtk_draw_insertion_cursor (widget, cr,
+                                 &cursor_location, TRUE, dir1,
+                                 dir2 != GTK_TEXT_DIR_NONE);
+
+      if (dir2 != GTK_TEXT_DIR_NONE)
         {
           cursor_location.x = xoffset + x2;
-          draw_insertion_cursor (entry, cr,
-                                 &cursor_location, FALSE, dir2,
-                                 TRUE);
+          gtk_draw_insertion_cursor (widget, cr,
+                                     &cursor_location, FALSE, dir2,
+                                     TRUE);
         }
     }
   else /* overwrite_mode */
index f7635213d35193c8396be4c1f3a855fe7c136e17..aa55e74e38135d1c03231554883c9bdda735af93 100644 (file)
@@ -3950,26 +3950,6 @@ get_layout_location (GtkLabel  *label,
     *yp = y;
 }
 
-static void
-draw_insertion_cursor (GtkLabel      *label,
-                       cairo_t       *cr,
-                      GdkRectangle  *cursor_location,
-                      gboolean       is_primary,
-                      PangoDirection direction,
-                      gboolean       draw_arrow)
-{
-  GtkWidget *widget = GTK_WIDGET (label);
-  GtkTextDirection text_dir;
-
-  if (direction == PANGO_DIRECTION_LTR)
-    text_dir = GTK_TEXT_DIR_LTR;
-  else
-    text_dir = GTK_TEXT_DIR_RTL;
-
-  gtk_draw_insertion_cursor (widget, cr, cursor_location,
-                            is_primary, text_dir, draw_arrow);
-}
-
 static PangoDirection
 get_cursor_direction (GtkLabel *label)
 {
@@ -4014,12 +3994,11 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
       PangoDirection keymap_direction;
       PangoDirection cursor_direction;
       PangoRectangle strong_pos, weak_pos;
+      GtkTextDirection dir1, dir2;
       gboolean split_cursor;
       PangoRectangle *cursor1 = NULL;
       PangoRectangle *cursor2 = NULL;
       GdkRectangle cursor_location;
-      PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
-      PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
 
       keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (widget)));
       cursor_direction = get_cursor_direction (label);
@@ -4033,16 +4012,16 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
                    "gtk-split-cursor", &split_cursor,
                    NULL);
 
-      dir1 = cursor_direction;
-      
+      dir1 = (cursor_direction == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+      dir2 = GTK_TEXT_DIR_NONE;
+
       if (split_cursor)
        {
          cursor1 = &strong_pos;
 
-         if (strong_pos.x != weak_pos.x ||
-             strong_pos.y != weak_pos.y)
+         if (strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y)
            {
-             dir2 = (cursor_direction == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+              dir2 = (cursor_direction == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
              cursor2 = &weak_pos;
            }
        }
@@ -4053,26 +4032,26 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
          else
            cursor1 = &weak_pos;
        }
-      
+
       cursor_location.x = xoffset + PANGO_PIXELS (cursor1->x);
       cursor_location.y = yoffset + PANGO_PIXELS (cursor1->y);
       cursor_location.width = 0;
       cursor_location.height = PANGO_PIXELS (cursor1->height);
 
-      draw_insertion_cursor (label, cr,
-                            &cursor_location, TRUE, dir1,
-                            dir2 != PANGO_DIRECTION_NEUTRAL);
-      
-      if (dir2 != PANGO_DIRECTION_NEUTRAL)
+      gtk_draw_insertion_cursor (widget, cr,
+                                 &cursor_location, TRUE, dir1,
+                                 dir2 != GTK_TEXT_DIR_NONE);
+
+      if (dir2 != GTK_TEXT_DIR_NONE)
        {
          cursor_location.x = xoffset + PANGO_PIXELS (cursor2->x);
          cursor_location.y = yoffset + PANGO_PIXELS (cursor2->y);
          cursor_location.width = 0;
          cursor_location.height = PANGO_PIXELS (cursor2->height);
 
-         draw_insertion_cursor (label, cr,
-                                &cursor_location, FALSE, dir2,
-                                TRUE);
+          gtk_draw_insertion_cursor (widget, cr,
+                                     &cursor_location, FALSE, dir2,
+                                     TRUE);
        }
     }
 }